/**
 * 
 */
package com.yidu.menuProject.action;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yidu.menuProject.action.vo.EhyManagerVo;
import com.yidu.menuProject.action.vo.ShowComment;
import com.yidu.menuProject.action.vo.UserComment;
import com.yidu.menuProject.common.Page;
import com.yidu.menuProject.model.CommentModel;
import com.yidu.menuProject.service.CommentService;
/**
 * 类的描述--评论的action
 * @author sylval
 * @date 2018年7月12日 上午11:54:41
 * @version 1.0
 */
@Controller
@RequestMapping("/commentAction")
public class CommentAction {
	@Resource
	CommentService comservice;
	/**
	 * 显示所有
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/showAjax")
	public Map<String,Object> showAjax(int page,int limit,HttpSession session){
		EhyManagerVo ehymanger=(EhyManagerVo) session.getAttribute("user");
		Page vo = new Page();
		vo.setNowpage(page-1);
		vo.setRows(limit);
		List<UserComment> userList = comservice.findComment(vo,ehymanger.getMealId());
		Map<String,Object> map=new HashMap<>();
		map.put("code", 0);
		map.put("msg", "1");
		map.put("count", comservice.findTotalRows(ehymanger.getMealId()));
		map.put("data", userList);
		return map;
	}
	
	@RequestMapping("/addComment")
	public String addComment(CommentModel record){
		comservice.insertSelective(record);
		return "index";
	}
	@ResponseBody
	@RequestMapping("/selectCommentByMeal")
	public List<ShowComment> SelectCommentByMeal(String mealId){
		List<ShowComment> mo=comservice.SelectCommentByMeal(mealId);
		return mo;
	}
}
